<?php
error_reporting(E_ALL|E_STRICT); ini_set('display_errors', 1);

$host = array_reverse(explode('.', $_SERVER['HTTP_HOST']));
$domain = $host[1].'.'.$host[0];
$subdomain = $host[2];
$host = $host[1];
$subdomain = isset($subdomain) ? $subdomain : 'www';

define("DOMAIN", $domain);
if (getenv("HTTPS") == 'on') {
	define('BASEURL', 'https://'.DOMAIN);
	$subdomain = 'www';
}else{
	define('BASEURL', 'http://'.$subdomain.'.'.DOMAIN);
}
// Get APPLICATION from url 
# Only implemeded for sub domain for the time being
# Will extend to domain later
switch ($subdomain) {
case 'mortgage':
    define("APPLICATION", 'mortgage');
    break;
case 'outdoor': //Outdoor Advertising
    define("APPLICATION", 'outdoor');
    break;
case 'dev': // Software Develoers Help Side
    define("APPLICATION", 'dev');
    break;
default:
	define("APPLICATION", 'default'); // www
}

define("ROOT", dirname(dirname(__FILE__)));
define("APPS", ROOT . DIRECTORY_SEPARATOR . 'apps');
define("CFG" , ROOT . DIRECTORY_SEPARATOR . 'config');

$zendLibs	= PATH_SEPARATOR . '/opt/zend/library';
$dirLibs	= PATH_SEPARATOR . ROOT . DIRECTORY_SEPARATOR . 'library'; 
$dirModels	= PATH_SEPARATOR . APPS . DIRECTORY_SEPARATOR . APPLICATION . DIRECTORY_SEPARATOR . 'models';
$dirForms	= PATH_SEPARATOR . APPS . DIRECTORY_SEPARATOR . APPLICATION . DIRECTORY_SEPARATOR . 'forms';

set_include_path('.'.$dirModels.$dirForms.$dirLibs.$zendLibs.':/usr/share/php');
unset($host,$domain,$subdomain,$dirModels,$dirForms,$dirLibs,$zendLibs);
//echo get_include_path(); exit; //Check your include path

require_once ROOT . DIRECTORY_SEPARATOR . 'bootstrap.php';

?>